package com.cqc.manage.service.Imp.equipmentService;


import com.cqc.manage.dto.EquRecordDto;
import com.cqc.manage.entity.Equipment;
import com.cqc.manage.entity.EquipmentRecord;
import com.cqc.manage.mapper.EquRecordMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquRecordService {

    @Autowired
    private EquRecordMapper equRecordMapper;

    private static final Logger logger = LoggerFactory.getLogger(EquRecordService.class);

    /**
     * 插入单条使用记录
     * @param equipmentRecord
     */
    public void addOneEquRecord(EquipmentRecord equipmentRecord){

        logger.info("插入一条数据：{}",equipmentRecord.toString());
        equRecordMapper.insert(equipmentRecord);

        return;

    }


    /**
     * 插入多条使用记录
     */
    public void addMultipleEquRecord(List<EquRecordDto> equipmentRecordList){
        logger.info("插入一条数据：{}",equipmentRecordList.toString());
        try {
            for (EquRecordDto equR:equipmentRecordList) {
                EquipmentRecord equipmentRecord = new EquipmentRecord();
                equipmentRecord.setEquName(equR.getEquName());
                equipmentRecord.setContractNo(equR.getContractNo());
                equipmentRecord.setEndDate(equR.getEndDate());
                equipmentRecord.setStartDate(equR.getStartDate());
                equipmentRecord.setEngineerName(equR.getUserName());
                equipmentRecord.setEquModel(equR.getEquModel());
                equipmentRecord.setEquNum(equR.getEquNum());
                equRecordMapper.insert(equipmentRecord);
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }

    }














}
